const { format } = require('../tool/tool.js');
const { lpush, lrange, llen, rpop } = require('../config/redis.js');

// 跟踪文件上传进度  

module.exports = {
  // 查询数据
  getData(req, res) {
    let { start, end } = req.query;
    // console.log(`req.query`, req.query)
    lrange(start, end, (err, response) => {
      if (err) {
        res.send(JSON.stringify({
          data: response || [], status: 0, success: false, message: '查询数据失败~~',
        }))
      }
      else {
        res.send(JSON.stringify({
          data: response || [], status: 1, success: true, message: '查询数据成功~~',
        }))
      }
    })
  },
  setData(req, resp) {
    lpush(req.body, err => {
      if (err) { resp.send({ status: 0, success: false, message: '留言失败~~' }) }
      else resp.send({ status: 1, success: true, message: '留言成功~~' })
    })
  },
}


